<template>
    <svg :class="svgClass" aria-hidden="true">
        <use :xlink:href="iconName" />
    </svg>
</template>

<script>
export default {
    name: 'SvgIcon',
    props: {
        iconClass: {
            type: String,
            required: true
        },
        className: {
            type: String
            // required: true
        }
    },
    computed: {
        iconName() {
            return `#icon-${this.iconClass}`;
        },
        svgClass() {
            if(this.className) {
                return 'svg-icon ' + this.className;
            }else {
                return 'svg-icon';
            }
        }
    }
};
</script>

<style scoped>
.svg-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.2em;
    /* currentColor: 使用color的颜色，color可继承自父类 */
    fill: currentColor;
    overflow: hidden;
    font-size: 14px;
}
</style>
